﻿#region Header
// Copyright 2007-2011, Jerónimo Milea
// 
// This file is part of NetJsWire.
// 
//     NetJsWire is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
// 
//     NetJsWire is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
// 
//     You should have received a copy of the GNU General Public License
//     along with NetJsWire.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System.ComponentModel;
using NetJsWire.Lite.Widgets.UI.Layout;
using Newtonsoft.Json;

namespace NetJsWire.Lite.Widgets.UI.Form
{
    public class FieldSetLW : Panel
    {
        public FieldSetLW()
            : this( null )
        {
        }

        public FieldSetLW( IContainer container )
            : base( container )
        {
            base.Xtype = "fieldset";
            base.Layout = LayoutType.Form;
        }

        /// <summary>
        ///   <tt>true</tt> to render a checkbox into the fieldset frame justin front of the legend to expand/collapse the fieldset when the checkbox is toggled. (defaults
        ///   to <tt>false</tt>).
        ///   <p>A {@link Ext.DomHelper DomHelper} element spec may also be specified to create the checkbox.
        ///     If <tt>true</tt> is specified, the default DomHelper config object used to create the element
        ///     is:</p><pre><code>
        ///                   {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'}
        ///                 </code></pre>
        /// </summary>
        [JsonProperty( "checkboxToggle" )]
        [DefaultValue( ( string ) null )]
        [TypeConverter( typeof( StringConverter ) )]
        public object CheckboxToggle { get; set; }

        /// <summary>
        ///   The name to assign to the fieldset's checkbox if <tt>{@link #checkboxToggle} = true</tt>(defaults to <tt>'[checkbox id]-checkbox'</tt>).
        /// </summary>
        [JsonProperty( "checkboxName" )]
        [DefaultValue( ( string ) null )]
        public string CheckboxName { get; set; }

        /// <summary>
        ///   <tt>true</tt> to make the fieldset collapsible and have the expand/collapse toggle button automatically
        ///   rendered into the legend element, <tt>false</tt> to keep the fieldset statically sized with no collapse
        ///   button (defaults to <tt>false</tt>). Another option is to configure <tt>{@link #checkboxToggle}</tt>.
        /// </summary>
        [JsonProperty( "collapsible" )]
        [DefaultValue( false )]
        [Description( "<tt>true</tt> to make the fieldset collapsible and have the expand/collapse toggle button automatically rendered into the legend element, <tt>false</tt> to keep the fieldset statically sized with no collapse button (defaults to <tt>false</tt>)." )]
        public override bool Collapsible { get; set; }

        /// <summary>
        ///   The base CSS class applied to the fieldset (defaults to <tt>'x-fieldset'</tt>).
        /// </summary>
        [JsonProperty( "baseCls" )]
        [DefaultValue( ( string ) null )]
        public override string BaseCls { get; set; }

        /// <summary>
        ///   <tt>true</tt> to animate the transition when the panel is collapsed, <tt>false</tt> to skip the
        ///   animation (defaults to <tt>false</tt>).
        /// </summary>
        [JsonProperty( "animCollapse" )]
        [DefaultValue( false )]
        public override bool AnimCollapse { get; set; }

        [DefaultValue( LayoutType.Form )]
        [JsonProperty( "layout", DefaultValueHandling = DefaultValueHandling.Ignore )]
        public override LayoutType Layout
        {
            get
            {
                return base.Layout;
            }
            set
            {
                base.Layout = value;
            }
        }
    }
}
